﻿package com.PlantVsZombies.Bullet;

import java.awt.Graphics;
import java.awt.Image;
import java.io.Serializable;

import com.PlantVsZombies.common.Life;

/**
 * 
 * 子弹爆炸类
 * 
 * @author Administrator
 *
 */
public class Bomb extends Life implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//爆炸坐标
	int x;
	int y;
	//爆炸生命
	int life = 3;
	//是否存在
	boolean isLive ;
	//爆炸图片
	Image image;
	
	public boolean getLive() {
		return isLive;
	}
	public void setLive(boolean isLive) {
		this.isLive = isLive;
	}
	public Bomb(int x, int y,Image image){
		this.x = x;
		this.y = y;
		this.image = image;
		this.isLive = true;
	}
	
	//画爆炸
	public void drawMe(Graphics g){
		if(this.isLive)
			g.drawImage(image, x+50, y, null);
	}
	public void drawMe(Graphics g,int w,int h){
		if(this.isLive)
			g.drawImage(image, x+50, y,w,h, null);
	}
	@Override
	public int doRun() {
		// TODO Auto-generated method stub
		if(life>0)
			life--;
		if(life == 0){
			this.isLive = false;
			return 0;
		}
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 1;
	}
}
